package com.wuzhen.wzzt.service.impl;

import com.wuzhen.wzzt.core.universal.AbstractService;
import com.wuzhen.wzzt.dao.db1.ActiveMapper;
import com.wuzhen.wzzt.dao.db1.EnrollMapper;
import com.wuzhen.wzzt.model.ActiveInfo;
import com.wuzhen.wzzt.model.EnrollUser;
import com.wuzhen.wzzt.service.ActiveService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
* @Description: ActiveService1接口实现类
* @author zhengzheng
* @date 2022/03/22 10:30
*/
@Service
public class ActiveServiceImpl extends AbstractService<ActiveInfo> implements ActiveService {

    @Resource
    private ActiveMapper activeMapper;

    @Resource
    private EnrollMapper enrollMapper;


    public List<ActiveInfo> selectFpList(String activeType){
        return activeMapper.selectFpList(activeType);
    }

    public List<ActiveInfo> selectList(String activeType){
        return activeMapper.selectList(activeType);
    }


    public List<ActiveInfo> selectListByOpenid(String openId){
        return activeMapper.selectListByOpenId(openId);
    }

    @Override
    public EnrollUser selectActiveInfoById(String activeId, String openId) {
        return enrollMapper.selectEnrollUserById(activeId,openId);
    }

    @Override
    public ActiveInfo selectActById(String id) {
        return activeMapper.selectActById(id);
    }


    public List<ActiveInfo> selectActByActiveStartTime() {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime tomorrow = now.plusDays(1);

        String activeStartTime = tomorrow.getYear() + "-" + tomorrow.getMonthValue() + "-" + tomorrow.getDayOfMonth();

        return activeMapper.selectActByActiveStartTime(activeStartTime);
    }
}